//
//  PVItemCell.m
//  wedding
//
//  Created by 常宽 on 15/1/27.
//  Copyright (c) 2015年 常宽. All rights reserved.
//

#import "PVItemCell.h"
#import "ItemModel.h"

#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height

@interface PVItemCell ()
///  封面
@property (nonatomic, retain) UIImageView *myImageView;
@end

@implementation PVItemCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.myImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.myImageView];
        
        // 阻止cell被选中
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.model = [[ItemModel alloc] init];
    }
    return self;
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    self.myImageView.frame = CGRectMake(5, 5, WIDTH - 10, HEIGHT - 10);
    self.myImageView.layer.cornerRadius = 10;
    self.myImageView.clipsToBounds = YES;
    self.myImageView.contentMode = UIViewContentModeScaleAspectFill;
    
    NSURL *url = [NSURL URLWithString:self.model.image_path];
    [self.myImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"NoPicture.jpg"]];
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
